<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>提问列表</title>
		<link rel="stylesheet" text="text.css" href="../../css.api.css"/>
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
	</head>
	<style>
		.mui-table-view-cell > a:not(.mui-btn) {
			padding: 10px;
		}
		/*					.mui-table-view-cell:active {
		 background: #fff;
		 }*/
		.cell-title {
			height: 22px;
		}
		.cell-subtitle, .message_content {
			height: 20px;
		}
		.right-div {
			width: 70px;
			float: right;
		}
		.left-div {
			margin-right: 70px;
		}
		.message_title {
			width: 90%;
			color: #222222
		}
		.right-tag {
			text-align: right;
		}
		.mui-table-view .mui-media-object {
			margin-top: 4px;
		}
		.discuss-del {
			width: 18px;
			margin-right: 0px;
		}
		.discuss-del-div {
			text-align: right;
			height: 40px;
		}
		.redPointMessage {
			top: 8px;
			left: 44px;
		}
	</style>
	<body>
		<div id="mian">
			<ul class="mui-table-view" id="stulist">
				<!--  <li class="mui-table-view-cell mui-media" >
				<a href="javascript:;"> <img class="mui-media-object mui-pull-left" src="../../image/inco_qusetion.png" >
				<div class="mui-media-body">
				<div class="right-div">
				<p class="mui-ellipsis base_grey content_p right-tag  top_30">
				</p>
				</div>
				<div class="left-div">
				<p class="mui-ellipsis base_dark_grey font16 cell-title">
				<span class="message_title"> 讨论名称 </span>
				</p>
				<p class="mui-ellipsis base_grey font14 content_p cell-subtitle top_10">
				<span class="file_submit_time"> 2017-01-02 14:20 </span>
				</p>
				</div>
				</div> </a>
				</li>-->
			</ul>
		</div>
		<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				老师端暂无设置问题
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button"  onclick="loadData()"class="mui-btn mui-btn-outlined">
				重新加载
			</button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script src="../../script/jquery.min.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../script/MD5.js"></script>
	<script src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script type="text/javascript" src="../../script/push.js"></script>
	<script type="text/javascript">
		var page = 1;
		var row = 10;
		var refreshCount = 0;
		apiready = function() {
			showProgress();
			loadData();
			sendBuriedNotifi('0', '学生端提问列表', '179');
			setRefreshHeader();
			setPullUpRefresh();
			setupNotifi();
		};
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}
		function setupNotifi() {
			api.addEventListener({
				name : 'pushMessage_classroomMessage'
			}, function(ret, err) {
				if (TW_TYPE == ret.value.type && $api.getStorage('cfnetppjxid') == ret.value.jid) {
					loadNewData();
				}
			});
		}

		//获取数据
		function loadData() {
			var params = {
				jid : $api.getStorage('cfnetppjxid'),
				uid : $api.getStorage('cfnetppuid'),
				tid : 2,
				page : page,
				rows : row,
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
			};
			//          alert(JSON.stringify(params));
			cfnetppPOST(url_stuGetActivelist, params, true, function(data, status) {
				//              alert(JSON.stringify(data));
				hideProgress();
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					if (data.code == 200) {
						var students = data.data;
						if (students != '' && students.constructor == Array && students.length > 0) {
							$('#noData').hide();
							$('#noNet').hide();
							$('#mian').show();
							refreshCount = students.length;
							writelist(students, students.length);
						} else {
							if (page == 1) {
								$('#noData').show();
								$('#noNet').hide();
							}
						}
					} else if (data.code = 108) {
						if (page == 1) {
							$('#noData').show();
							$('#noNet').hide();
							$('#mian').hide();
						}
					} else {
						if (page == 1) {
							$('#noData').show();
							$('#noNet').hide();
							$('#mian').hide();
						}
					}
				} else {
					$('#noData').hide();
					$('#noNet').show();
					$('#mian').hide();
				}
			});
		}

		function questionDetailClick(id, type, name) {
			//          uploadReadStatus(id);
			$("#redPoint" + id).hide();
			if (type == 1) {//经行中
				$("#redPoint" + id).hide();
				api.openWin({useWKWebView:true,
					name : 'TeacherQusertionNamesWind',
					url : '../Teacher_Classroom/TeacherQusertionNamesWind.html',
					pageParam : {
						id : id,
						type : 3,
                        sourceurl : window.location.pathname,
					    sourcetitle : document.title
					}
				});
			} else {
				api.openWin({useWKWebView:true,
					name : 'TeacherQusestionInfo',
					url : '../Teacher_Classroom/TeacherQusestionInfo.html',
					pageParam : {
						name : name,
						id : id,
						is_teacher:false,
                        sourceurl : window.location.pathname,
					    sourcetitle : document.title
					},
				});
			}
			//
		}
		
     function writelist(listdata,len){
          var htmls='';
          for(var i=0;i<len;i++){
            var data = listdata[i];
            var times =data.starttime;
            if(times==null||times==''){
                times = data.createtime;
            }
              var new_message = "";
              var activestatus = data.activestatus;

               if(activestatus == 1){//已开始
				 new_message = '<div id="redPoint'+ data.id + '" class="redPointMessage"></div>';
	        	}
                     var strhtml = '  <li class="mui-table-view-cell mui-media"  onclick="questionDetailClick('+data.id+','+activestatus+','+"'"+data.name+"'"+')">'+
				 ' <a href="javascript:;"  style="position:relative;">' + new_message + '<img class="mui-media-object mui-pull-left" src="../../image/inco_qusetion.png" >'+
				 ' <div class="mui-media-body">'+
				 ' <div class="right-div">'+
				 ' <p class="mui-ellipsis base_grey content_p right-tag  top_30">'+
			
				 ' </p>'+
				 ' </div>'+
				 ' <div class="left-div">'+
				 ' <p class="mui-ellipsis base_dark_grey font14 cell-title">'+
				 ' <span class="message_title"> '+ data.name+' </span>'+
				 ' </p>'+
				 ' <p class="mui-ellipsis base_grey font12 content_p cell-subtitle top_10">'+
				 ' <span class="file_submit_time"> '+timeWithStamp3(times)+'</span>'+
				 ' </p>'+
				 ' </div>'+
				 ' </div> </a>'+
				 ' </li>';
               htmls = htmls +strhtml;
		     }
		  	if (page == 1) {
				$('#stulist').html(htmls);
			} else {
				$('#stulist').append(htmls);
			
          }
        }

		/*
		 修改课堂信息状态
		 */
		function uploadReadStatus(id) {
			var params = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				iid : id,
				tid : 2
			};
			cfnetppPOST(url_classroomMessageSetStatus, params, false, function(data, status) {
			});
		}
	</script>
</html>